﻿<Page x:Class="Samples.Pages.GeographicPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="GeographicSample"
    xmlns:l="clr-namespace:TreeMaps.Controls;assembly=TreeMaps"
    >
  <Page.Resources>
    <!--<l:ValueDataTemplate AreaValue="{Binding Path=Sales}" x:Key="test">
      <Border BorderThickness="2" BorderBrush="Blue">
        <Grid>
          <Viewbox Stretch="Fill">
            <Grid>
              <Image Source="{Binding Path=Image}" Width="128" Height="128" Stretch="Fill"/>
              <StackPanel Orientation="Vertical" VerticalAlignment="Center" HorizontalAlignment="Center">
                <TextBlock  TextWrapping="Wrap" Text="{Binding Path=Name}"/>
                <StackPanel Orientation="Horizontal">
                  <TextBox Text="{Binding Path=Sales}"/>
                  <TextBlock Margin="5,0,0,0">€</TextBlock>
                </StackPanel>
              </StackPanel>
            </Grid>
          </Viewbox>
        </Grid>
      </Border>
    </l:ValueDataTemplate>-->
    
    <DataTemplate x:Key="geographicAreaDataTemplate">
      <Border BorderThickness="2" BorderBrush="Blue">
        <Grid>
          <Viewbox Stretch="Fill">
            <Grid>
              <Image Source="{Binding Path=Image}" Width="128" Height="128" Stretch="Fill"/>
              <StackPanel Orientation="Vertical" VerticalAlignment="Center" HorizontalAlignment="Center">
                <TextBlock  TextWrapping="Wrap" Text="{Binding Path=Name}"/>
                <StackPanel Orientation="Horizontal">
                  <TextBox Text="{Binding Path=Sales}"/>
                  <TextBlock Margin="5,0,0,0">€</TextBlock>
                </StackPanel>
              </StackPanel>
            </Grid>
          </Viewbox>
        </Grid>
      </Border>
    </DataTemplate>
  </Page.Resources>
  
    <Grid>
      <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition/>
      </Grid.RowDefinitions>

      <ComboBox x:Name="_mode" Grid.Row="0" />
      
      <l:TreeMaps
        Grid.Row="1" 
        x:Name="_tree"
        ItemTemplate="{StaticResource geographicAreaDataTemplate}"
        ValuePropertyName="Sales"
        TreeMapMode="Squarified"
      />
    </Grid>
</Page>
